<?
if (stack('id')) {
	
	if (!function_exists('cpnStringListData')) {
		function cpnStringListData($_id_component, $_lang = '') {
			global $DATA;

//			$_id_component	= $DATA['components'][$c]['id'];			//	list id value
			$_id_data		= D_MB_DATA;			//	meta id value
			$_id_meta		= D_MB_META;			//	meta id value
			
			$_crit = "id_data=$_id_data AND id_parent=$_id_component AND ".dbAndL('attr', AA_VISIBLE);
		
		//	$s = array_extend( array('path' => 'sections', 'w' => 400, 'h' => 300, 'caption' => ''), $DATA['components'][$c]['settings']);
		
			$data = array_mark_bounds( datafetch_array('db_list', array('table' => tb('data'), 'where' => "$_crit",	'order' => 'id_index', 'index' => 'id' )));

			$meta = datafetch_array('db_list', array(
				'table' => tb('data'), 
				'where' => "id_data=$_id_meta AND id_parent in (".implode(',', array_keys($data)).')',	
				'index' => 'id', 
			));
			
			foreach($meta as $k => $v) {
				if ($v['assoc'])
					$data[$v['id_parent']]['meta'][$v['name']][$v['assoc']] = $v['value'];
				else
					$data[$v['id_parent']][$v['name']] = $v['value'];
			}
		
			foreach($data as $k => $v) {
		
				if (isset($v['meta'])) 	// parse language dependent data
					foreach($v['meta'] as $mname => $mv) {
						if ($mv[$_lang] && ($mv[$_lang] != -1))
							$data[$k][$mname] = $mv[$_lang];
						else {	// no data in current language, get any other we can find
							foreach($DATA['langs'] as $lid => $lv) {
								if ($mv[$lid] && ($mv[$lid] != -1)) {
									$data[$k][$mname] = $mv[$lid];
									break;
								}
							}
						}
					}
			}

			return $data;
		}
	}
	
	
	return unstack(cpnStringListData(stack('id'), stack('lang', '')));
}